n,k,t,xl,yd,xr,yu=map(int,input().split())

result=[0,0]

for i in range(0,n):
    flag=[0,0]
    dou=0
    nums=list(map(int,input().split()))
    for j in range(0,t):
        x=nums[j*2]
        y=nums[j*2+1]
        if x>=xl and x<=xr and y>=yd and y<=yu:
            flag[0]=1
            dou+=1
            if dou>=k:
                flag[1]=1
                break
        else:
            dou=0
    result[0]+=flag[0]
    result[1]+=flag[1]

print(result[0])
print(result[1])